﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using StudyCSharpProject.ConsoleHello;

namespace ReflectionHello
{
    public class UsingReflectionClass
    {
        public UsingReflectionClass() 
        {
            HelloConsole obj = new HelloConsole();
            Type t = obj.GetType();
            Console.WriteLine("Тип {0}: {1} , значение: {2}",
                "HelloConsole", t, obj.ToString());
            Console.WriteLine("Методы класса:");
            MethodInfo[] ClassMethods = t.GetMethods();
            foreach (MethodInfo curMethod in ClassMethods)
            {
                Console.WriteLine(curMethod);
            }
            Console.WriteLine("Все члены класса:");
            MemberInfo[] ClassMembers = t.GetMembers();
            foreach (MemberInfo curMember in ClassMembers)
            {
                Console.WriteLine(curMember.ToString());
            }	

        }
        public void WhoIsWho(string name, object any)
        {
            Type t = any.GetType();
            Console.WriteLine("Тип {0}: {1} , значение: {2}",
                name, any.GetType(), any.ToString());
            Console.WriteLine("Методы класса:");
            MethodInfo[] ClassMethods = t.GetMethods();
            foreach (MethodInfo curMethod in ClassMethods)
            {
                Console.WriteLine(curMethod);
            }
            Console.WriteLine("Все члены класса:");
            MemberInfo[] ClassMembers = t.GetMembers();
            foreach (MemberInfo curMember in ClassMembers)
            {
                Console.WriteLine(curMember.ToString());
            }
        }
    }
}
